<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      
      <el-table-column prop="username" label="用户账号" width="180">
      </el-table-column>
    
      <el-table-column prop="typename" label="评论类型" width="100">
      </el-table-column>
      <el-table-column prop="content" label="评论内容" width="200">
      </el-table-column>
      <el-table-column prop="topid" label="上级评论账号"> </el-table-column>
      <el-table-column prop="topcontent" label="上级评论内容">
      </el-table-column>
      <el-table-column prop="time" label="评论时间"> </el-table-column>
      <el-table-column prop="state" label="状态"> </el-table-column>
      <el-table-column prop="deltime" label="删除时间"> </el-table-column>
      <el-table-column prop="operate" label="操作" @click="del(1)">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: ["tableData","name"],
  data() {
    return {
      currentPage: 1,
      //   tableData: [
      //     {
      //      username: "1",
      //       typename: "一级评论",
      //       content: "上海市普陀区金沙江路 1518 弄",
      //       topid:"-",
      //       topcontent:"xxxxxxxx",
      //       time:"2021/01/01",
      //       state:"-",
      //       deltime:"2021/01/01",
      //     //   operate:"删除"
      //     },
      //     {
      //       username: "2",
      //       typename: "一级评论",
      //       content: "上海市普陀区金沙江路 1517 弄",
      //       topid:"-",
      //       topcontent:"xxxxxxxx",
      //       time:"2021/01/01",
      //       state:"-",
      //       deltime:"2021/01/01",
      //     //   operate:"删除"
      //     },
      //     {
      //       username: "3",
      //       typename: "一级评论",
      //       content: "上海市普陀区金沙江路 1519 弄",
      //       topid:"-",
      //       topcontent:"xxxxxxxx",
      //       time:"2021/01/01",
      //       state:"-",
      //       deltime:"2021/01/01",
      //     //   operate:"删除"
      //     },
      //     {
      //       username: "4",
      //       typename: "一级评论",
      //       content: "上海市普陀区金沙江路 1516 弄",
      //       topid:"-",
      //       topcontent:"xxxxxxxx",
      //       time:"2021/01/01",
      //       state:"-",
      //       deltime:"2021/01/01",
      //     //   operate:"删除"
      //     },
      //   ],
    };
  },
  mounted() {
    console.log(this.tableData,this.name);
  },

  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleClick(data) {
      console.log("删除");
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style>
.el-table .cell {
  width: 200px;
  overflow: hidden;
  white-space: nowrap;

  text-overflow: ellipsis;

  -o-text-overflow: ellipsis;
}
</style>